#include "CPlayerIdleState.h"
#include "CPlayer.h"
#include "CPlayerWalkState.h"
#include "CPlayerJumpState.h"
#include "CSGD_DirectInput.h"
#include "CTimer.h"

CPlayerIdleState::CPlayerIdleState()
{
	m_vAnimations.push_back(CAnimationEngine::GetInstance()->LoadAnimation(Greek_Idle));
	m_vAnimations.push_back(CAnimationEngine::GetInstance()->LoadAnimation(MidEvil_Idle));
	m_vAnimations.push_back(CAnimationEngine::GetInstance()->LoadAnimation(Gothic_Idle));
}

CPlayerIdleState *CPlayerIdleState::GetInstance()
{
	static CPlayerIdleState Instance;
	return &Instance;
}

void CPlayerIdleState::Enter(CPlayer *pPlayer)
{
	m_pPlayer = pPlayer;
}

void CPlayerIdleState::Run()
{
	m_vAnimations[m_pPlayer->m_unTimePeriod]->Play(CTimer::GetInstance()->GetElapsedTime());

	CSGD_DirectInput * di = CSGD_DirectInput::GetInstance();
	if(di->KeyDown(DIK_RIGHTARROW)|| di->KeyDown(DIK_LEFTARROW))
	{
		m_pPlayer->ChangeState(	CPlayerWalkState::GetInstance());
	}
	if(di->KeyDown(DIK_UPARROW))
	{
		Vec3 Up(m_pPlayer->m_Pos.x, m_pPlayer->m_Pos.y, 0);
		Up.Normalize();
		Up *= m_pPlayer->m_fJumpSpeed;
		m_pPlayer->m_Vel = Up;
		float x = Up.Length();
		m_pPlayer->ChangeState(	CPlayerJumpState::GetInstance());
	}
}

void CPlayerIdleState::Exit()
{
}